﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Simhopp.Model;

namespace Simhopp.GUI
{
    public partial class frmLogin : Form , InterfaceLogInView
    {
        public static bool databaseConnection = true;
        public event DelegateLogIn EventLogIn = null;
        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (EventLogIn != null)
            {
                EventLogIn();
                this.Hide();
                this.Close();
                
            }
        }

        public bool DatabaseConnection
        {
            get { return databaseConnection; }

            set 
            { 
                if(value != databaseConnection)
                {
                    databaseConnection = value;
                    if (databaseConnection == true)
                        tsslDataConnect.Text = "Connected";
                    else
                        tsslDataConnect.Text = "Not Connected";
                }
            }
        }

        private void btnGuest_Click(object sender, EventArgs e)
		{
			#region CommentedOldCode
                frmJudgeScreen fJudgeScreen = new frmJudgeScreen(new Judge());
                if (txtUsername.Text == "1")
                {
                    fJudgeScreen = new frmJudgeScreen(new Judge(1, "Amanda", Countries.Afghanistan, "hej", "hopp"));
                }
                if (txtUsername.Text == "2")
                {
                    fJudgeScreen = new frmJudgeScreen(new Judge(2, "John", Countries.Afghanistan, "hej", "hopp"));
                }
                if (txtUsername.Text == "3")
                {
                    fJudgeScreen = new frmJudgeScreen(new Judge(3, "Kjell Kod", Countries.Afghanistan, "hej", "hopp"));
                }
                if (txtUsername.Text == "4")
                {
                    fJudgeScreen = new frmJudgeScreen(new Judge(4, "Rohan", Countries.Afghanistan, "hej", "hopp"));
                }
                if (txtUsername.Text == "5")
                {
                    fJudgeScreen = new frmJudgeScreen(new Judge(5, "Hanzel", Countries.Afghanistan, "hej", "hopp"));
                }

                fJudgeScreen.ShowDialog();
       
            
			
			#endregion

            //Database.DBConnect DB = new Database.DBConnect();
            //frmJudgeScreen fJudgeScreen;
            //Judge judy;
            //judy = DB.JudgeLogin(txtUsername.Text, txtPassword.Text);


            //if (judy != null)
            //{
            //    fJudgeScreen = new frmJudgeScreen(judy);
            //    this.Close();
            //}
            //else
            //    System.Windows.Forms.MessageBox.Show("Wrong password or username");
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {

        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
